package com.douqu.game.core.config;

import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.factory.LoadFactory;
import com.douqu.game.core.util.LoadUtils;
import com.douqu.game.core.util.LogUtils;

/**
 * @author wangzhenfei
 *         2017-12-04 14:32
 *         充值配置
 */
public class RechargeGuideConfig extends GameObject{

    public String icon;

    public String remark;

    public int  srcRmb;

    public int  nowRmb;

    /**条目id**/
    public int[]  itemIds;

    /**推荐星级**/
    public int  star;

    public int rechargeType;


    @Override
    public boolean check()
    {
        if(itemIds != null)
        {
            for(int id : itemIds){
                if(DataFactory.getInstance(LoadFactory.isTestLoad()).getGameObject(DataFactory.RECHARGE_GUIDE_ITEM_KEY, id) == null){
                    LogUtils.error("RechargeGuideConfig check itemIds is error -> id:" + id + " name:" + name);
                    return false;
                }
            }

        }
        return true;
    }


    @Override
    public boolean setVariable(String key, String value)
    {

        if("itemIds".equals(key)){
            itemIds = LoadUtils.loadIntArray(key, value);
            if(itemIds == null){
                LogUtils.error("RechargeGuideConfig check itemIds is null -> id:" + id + " name:" + name);
                return false;
            }
            return true;
        }
        else
            return super.setVariable(key, value);
    }

}
